<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>文件上传实例</title>
    <script src="/js/jquery/jquery_wev8.js"></script>
    <script type="text/javascript">
        function checkSubmit() {
            var fileSize=$("#uploadFile")[0].files[0].size;
            var newFileSize=Math.round(fileSize/(1024*1024));
            console.log("上传的文件大小："+newFileSize+"M");
            if(newFileSize>40){
                alert("上传的文件过大,上传上限为40M");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<h1>文件上传实例</h1>
<form method="post" action="/UploadServlet" enctype="multipart/form-data" onsubmit="return checkSubmit()">
    选择一个文件:
    <input type="file" name="uploadFile" id="uploadFile"/>
    <br/><br/>
    <input type="submit"  value="上传"/>
</form>
</body>
</html>